var getDialog1Option = function () {
  return  {
    dataset: {
      source: [
        ['amount', 'product'],
        [50, '淳安县'],
        [100, '富阳区'],
        [250, '桐庐区'],
        [350, '滨江区'],
        [400, '萧山区'],
        [400, '临安区'],
        [600, '上城区'],
        [750, '余杭区'],
        [1250, '临平区'],
        [1400, '钱塘区'],
        [1650, '建德市'],
        [2200, '西湖区'],
        [2600, '拱墅区'],
      ]
    },
    tooltip: {
      trigger: 'axis',
      backgroundColor:'#fff',
      textStyle:{
        color:'#000',
        lineHeight:'24px',
      },
      padding:[15,80,15,20],
      //label格式化
      formatter : function(params){
        if(params.length > 0 ){
          let h1 = `<div style="font-size:18px;font-weight:600;margin-bottom:6px">${params[0].name}</div><p>出租：${params[0].data[0]}</p><p>占比：${Math.round((params[0].data[0]/12000)*100)}%</p>`;
          return h1;
        }else{
          return ''
        }
      },
      axisPointer: {
        // 坐标轴指示器，坐标轴触发有效
        type: 'shadow', // 默认为直线，可选为：'line' | 'shadow'
      },
    },
    grid: {
      top:'3%',
      left: "3.8%",
      right: "5%",
      bottom: "3%",
      containLabel: true,
    },
    xAxis: {
      name: '',
      axisLabel: {
        color: '#fff',
        fontSize: 14,
        margin: 20,
        align: 'center'
      },
      splitLine: {
        show: true,
        lineStyle: {
          width: 1,
          type:"dashed",
          color:'#4F4F4F',
        }
      },
    },
    yAxis: {
      type: 'category',
      axisLabel: {
        color: '#fff',
        fontSize: 14,
        margin: 20,
        align: 'center'
      },
      axisLabel: {
        padding: [2,10,2,0],
        color:'#ffffff',
      }
     },
    series: [
      {
        type: 'bar',
        barWidth:10,
        color:'#023AFF',
        encode: {
          // Map the "amount" column to X axis.
          x: 'amount',
          // Map the "product" column to Y axis
          y: 'product'
        }
      }
    ]
  }
}

var dialog1BoxDom = document.getElementById('dialog1Box');
let dialog1BoxChart = echarts.init(dialog1BoxDom);


$(function () {
  dialog1BoxChart.setOption(getDialog1Option())
})
